Postgresql13 Linux7 安装
1 调整操作系统时间
2 安装脚本
# Install the repository RPM:
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# Install PostgreSQL:
sudo yum install -y postgresql13-server postgresql13-contrib
# Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
sudo systemctl enable postgresql-13
sudo systemctl start postgresql-13
3 操作系统配置
3.1 配置sudo 权限(可选)
usermod -aG wheel postgres
passwd postgres
3.2 环境变量设置
cp ~/.bashrc /var/lib/pgsql/
chown postgres:postgres /var/lib/pgsql/.bashrc
cat >> ~/.bash_profile << EOF
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=\$PATH:\$HOME/bin
export PATH
export PATH=/usr/pgsql-13/bin:\$PATH
# 可选,远程测试使用
export PGPORT=5432
export PGUSER=postgres
EOF
source ~/.bash_profile
3.3 配置git(可选)
yum install git
3.4 安装vim
yum install vim
4 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
5 数据库配置
5.1 更改postgersql 密码
su - postgresql
alter user postgres password 'kingbase';
5.2 更改监听地址
alter system set listen_addresses ='*';
5.3 设置TCP/IP 连接方式
注意IPv4 的 条目: 允许192.168.10.X
网段的主机连接.
vi $PGDATA/pg_hba.conf
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 scram-sha-256
host all all 0.0.0.0/0 scram-sha-256
# IPv6 local connections:
host all all ::1/128 scram-sha-256
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 scram-sha-256
host replication all ::1/128 scram-sha-256
5.4 设置监听端口
alter system set listen_addresses = '*' ;
5.5 重启数据库
pg_ctl restart -D $PGDATA
6 配置管理脚本
- 下载管理脚本
- 上传管理脚本到
PGDATA
中.